/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.latticeware.xtalk.stack;

import com.latticeware.xtalk.app.ObjectFactory;
import java.awt.Frame;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;



/**
 *
 * @author sfisque
 * 
 */
public class Stack
extends VisualThing
{
    protected List<Card> cards;
    
    protected Integer currentIndex;
    
    
    public Stack()
    {
        super( 0, new Frame() );
        
        cards = new ArrayList<Card>( 7 );
        cards.add( ObjectFactory.getInstance().newCard() );
        
        currentIndex = 0;
    }
    
    @Override
    protected Type getType()
    {
        return Stack.class;
    }


    public Integer getCurrentIndex()
    {
        return currentIndex;
    }


    public void setCurrentIndex(Integer currentIndex)
    {
        this.currentIndex = currentIndex;
    }
    
    
    public Card getCurrentCard()
    {
        if( currentIndex != null )
        {
            return cards.get( currentIndex );
        }
        
        return null;
    }



    @Override
    public int hashCode()
    {
        return 0;
    }


    @Override
    public boolean equals(Object o)
    {
        if( o == null || ! ( o instanceof Stack ) )
        {
            return false;
        }
        
        return ((Stack) o).id.equals( this.getId() );
    }
    
}
